package bean.srv;

import xmlparsers.SystemParser;
import xmlparsers.XMLBuilder;
import bean.dao.HibernateRemitoDAO;
import dominio.Remito;


public class RemitoSRV 
{
	HibernateRemitoDAO dao = HibernateRemitoDAO.getInstancia();

	public void crearRemito (Remito r) {
		dao.crearRemito (r);
	}
	
	public Remito buscarRemito (int id) {
		return dao.buscarRemito(id);
	}
	
	public Remito buscarRemitoPorNro (int num) {
		return dao.buscarRemitoPorNro(num);
	}

	public Remito crearXMLPorId (int id ,String path) {
		Remito r = this.buscarRemito(id); 
		XMLBuilder.getInstance().createRemitoXML(r, path);
		return r;
	}
	
	public Remito crearXMLPorNro (int num ,String path) {
		Remito r = this.buscarRemitoPorNro(num);
		XMLBuilder.getInstance().createRemitoXML(r, path);
		return r;
	}
	
	public Remito persitirXMLFile (String filepath)  {
		Remito r = SystemParser.getInstance().parseRemito(filepath);
		dao.crearRemito(r);
		return r;
	}
	
}
